//package com.college.mvc.config;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
//import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
//import org.springframework.security.config.annotation.web.builders.HttpSecurity;
//import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
//import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
//import org.springframework.security.core.userdetails.UserDetailsService;
//import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
//
//@Configuration
//// 启用Web环境下权限控制功能
//@EnableWebSecurity
//// 启用全局方法权限控制功能，并设置prePostEnabled = true， 保证几个注解生效
//@EnableGlobalMethodSecurity(prePostEnabled = true)
//public class WebAppSecurityConfig extends WebSecurityConfigurerAdapter {
//    @Autowired
//    private UserDetailsService userDetailsService;
//    @Bean
//    public BCryptPasswordEncoder getPasswordEncoder(){
//        return new BCryptPasswordEncoder();
//    }
//    @Override
//    protected void configure(AuthenticationManagerBuilder builder) throws Exception {
//        /*builder.inMemoryAuthentication().withUser("tom").password("123123").roles("ADMIN");*/
////        builder.userDetailsService(userDetailsService).passwordEncoder(getPasswordEncoder());
//        builder.userDetailsService(userDetailsService);
//    }
//    @Override
//    protected void configure(HttpSecurity security) throws Exception {
//        /*        security.authorizeRequests()
//                .antMatchers("/admin/to/login/page.html", "/bootstrap/**", "/crowd/**", "/css/**", "/fonts/**", "/img/**", "/jquery/**", " /layer/**", "/script/**", "/ztree/**")
//                .permitAll()
//                .antMatchers("/admin/get/page.html")
//                .hasRole("经理")
//                .anyRequest()
//                .authenticated()
//                .and()
//                .exceptionHandling()
//                //.accessDeniedPage("/to/no/auth/page.html")
//                .accessDeniedHandler(new AccessDeniedHandler() {
//                    @Override
//                    public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AccessDeniedException e) throws IOException, ServletException {
//                        httpServletRequest.setAttribute("message", CrowdConstant.MESSAGE_LOGIN_DENIED);
//                        httpServletRequest.getRequestDispatcher("/WEB-INF/system-error.jsp").forward(httpServletRequest, httpServletResponse);
//                    }
//                })
//                .and()
//                .csrf()
//                .disable()
//                .formLogin()
//                .loginPage("/admin/to/login/page.html")
//                .permitAll()
//                .loginProcessingUrl("/security/do/login.html")
//                .permitAll()
//                .usernameParameter("loginAcct")
//                .passwordParameter("userPswd")
//                .defaultSuccessUrl("/admin/to/main/page.html")
//                .and()
//                .logout()
//                .logoutUrl("/security/do/logout.html")
//                .logoutSuccessUrl("/admin/to/login/page.html")
//        ;*/
//        security.authorizeRequests()
//                .antMatchers("/admin/to/login/page.html","/bootstrap/**","/css/**","/fonts/**","/img/**","/jquery/**"," /layer/**","/script/**","/ztree/**")
//                .permitAll()
//                .anyRequest()
//                .authenticated()
//                .and()
//                .formLogin()
//                .loginPage("/admin/to/login/page.html")
//                .loginProcessingUrl("/security/login.html")   // 匹配表单的action属性值
//                .successForwardUrl("/admin/to/main/page.html")
//                .failureForwardUrl("/admin/to/login/page.html")
//                .permitAll();
//    }
//}